package com.parking.mgr.useraccount.controller;

import com.parking.mgr.common.annotion.BusinessLog;
import com.parking.mgr.common.annotion.LoginAuth;
import com.parking.mgr.common.annotion.PermissionUrl;
import com.parking.mgr.common.pojo.response.Result;
import com.parking.mgr.useraccount.model.param.UserPhoneParam;
import com.parking.mgr.useraccount.service.UserPhoneService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @ClassName BasicUserController
 * @Description 系统用户控制器
 * @Auther: zhijianpu
 * @Date: 2023/5/25
 */
@Api(value = "用户手机号(登录用户)", tags = {"用户手机号(登录用户)"})
@RequestMapping("/api/user/phoneself")
@RestController
public class UserPhoneSelfController {

    @Resource
    private UserPhoneService userPhoneService;

    /**
     * 通过client_id 和 login_token 获取passportId添加用户
     *
     */
    @PostMapping("/add")
    @ApiOperation(value = "添加登录用户手机号", notes = "添加登录用户手机号", httpMethod = "POST")
    @BusinessLog(title = "添加登录用户手机号")
    @LoginAuth
    @PermissionUrl
    public Result<?> addSelfUserPhone(@RequestBody @Validated(UserPhoneParam.add.class) UserPhoneParam userPhoneParam, HttpServletRequest request) {
        userPhoneService.addSelfUserPhone(userPhoneParam, request);
        return Result.success();
    }


    /**
     * 通过client_id 和 login_token 获取passportId修改手机号
     *
     */
    @PostMapping("/edit")
    @ApiOperation(value = "修改登录用户手机号", notes = "修改登录用户手机号", httpMethod = "POST")
    @BusinessLog(title = "修改登录用户手机号")
    @LoginAuth
    @PermissionUrl
    public Result<?> editUserPhone(@RequestBody @Validated(UserPhoneParam.edit.class) UserPhoneParam userPhoneParam, HttpServletRequest request) {
        userPhoneService.editUserPhone(userPhoneParam, request);
        return Result.success();
    }


}
